package com.asia5b.a5mall.home.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.asia5b.a5mall.home.R
import com.asia5b.a5mall.middleware.utils.appLanguageSelect
import com.asia5b.a5mall.middleware.model.bean.ChoiceLanguageBean
import com.asia5b.a5mall.middleware.utils.WImageLoader
import de.hdodenhof.circleimageview.CircleImageView

/**
 * Created by zhangyuncai on 2019/11/15.
 */
class ChoiceLanguageAdapter(
        list: ArrayList<ChoiceLanguageBean>
)
    : BaseQuickAdapter<ChoiceLanguageBean, BaseViewHolder>(R.layout.item_choicelanguage_adapter, list) {
    var select_language = appLanguageSelect;

    override fun convert(helper: BaseViewHolder, item: ChoiceLanguageBean) {
        //国家旗帜
        val iv_choicelanguage_countrytag = helper.getView<CircleImageView>(R.id.iv_choicelanguage_countrytag)
        WImageLoader.displayImage(item.countryTag,iv_choicelanguage_countrytag,R.drawable.img_default)
        //国家名称
        val tv_choicelanguage_countryname = helper.getView<TextView>(R.id.tv_choicelanguage_countryname)
        tv_choicelanguage_countryname.text = item.countryName
        //App设置的语言
        val tv_choicelanguage_check = helper.getView<TextView>(R.id.tv_choicelanguage_check)
        tv_choicelanguage_check.isSelected = select_language == item.language
    }
}